import { CHANGE_INPUT, ADD_ITEM, DELETE_ITEM, GET_LIST }  from './actionTypes'
import axios from 'axios'

export const changeInputAction = (value)=>({
    type:CHANGE_INPUT,
    value
})

export const addItemAction = ()=>({
    type:ADD_ITEM
})

export const deleteItemAction = (index)=>({
    type:DELETE_ITEM,
    index
})

export const getListAction = (data)=>({
  type:GET_LIST,
  data
})

export const getTodoList = () =>{
  return (dispatch)=>{
      axios.get('https://rapserver.sunmi.com/app/mock/241/GET/todolist').then((res)=>{
          const data = res.data
          // console.log('27data', data)
          const action = getListAction(data)
          dispatch(action)
      })
  }
}